The \f3Queue<Type>\f1 class implements a conventional first-in, first-out data
structure that holds a user-specified data type. All memory management and
initialization is encapsulated and performed by the class constructors and
member functions. Queue objects can be either static-sized or dynamic. Queues
are, by default, dynamic in nature. A static-sized queue object is selected by
setting the growth allocation size to zero or by passing in a pointer to a
block of user-supplied storage to the constructor. If a queue is of static size
and an operation is performed that requires more storage, an
\f3\f3Error\f1\f1
exception is
raised.
.PP
The \f3Queue<Type>\f1 class implements the notion of a current position. This is
useful for iterating through the elements of a queue. The current position is
maintained in a data member of type
Queue_state
and is set or reset by all
member functions affecting elements in the class. Member functions are
provided to reset the current position, move to the next and previous
elements, find an element, and get the value at the current position. The \f3Iterator<Type>\f1 class provides a mechanism to save and restore the state
associated with the current position, thus allowing the programmer to use
multiple iterators over the same instance of a queue.
.PP
The \f3Queue<Type>\f1 class allows the programmer to add and/or remove items from
either end of the queue. In addition, the current position and iterator
functions allow the programmer to examine other entries in the middle of the
queue and remove or change them. This would be useful in implementing a
prioritized queue where the entries may need to be rearranged at times.
.SH Base Classes
Queue,
.SH Friend Classes
None
.SH Constructors
.TP
\f3Queue<Type> ();\f1
Creates an empty queue of the specified type.
.TP
\f3Queue<Type> (unsigned long \f2number\f3);\f1
Allocates enough storage for a queue of a specific type to hold
number of
elements specified by the argument.
.TP
\f3Queue<Type> (const Queue<Type>& q\f3);\f1
Duplicates the size and value of a queue object
q .
.TP
\f3Queue<Type> (void* \f2storage\f3, unsigned long \f2number\f3);\f1
Creates a static-sized queue object for
number
of elements whose storage
storage
is provided by the user. If an object of this type attempts to grow
dynamically or the programmer invokes the
resize
member function, an
\f3\f3Error\f1\f1
exception is raised.
.SH Member Functions
.TP
inline long capacity () const;
Returns the maximum number of elements the stack can contain.
.TP
void clear ();
Sets the number of items in the queue to zero. This function invalidates the
current \p
position.
.TP
inline Queue_state& current_position ();
Returns a reference to the state information associated with the current
position. This function should be used with the \f3Iterator<Type>\f1 class to save
and restore the current position, thus facilitating multiple iterators over an
instance of queue.
.TP
\f3Boolean find (const Type& value\f3);\f1
Searches the queue for
value .
If
value
is found, this function sets the current
position and returns
TRUE ;
otherwise, this function resets the current position
and returns
FALSE .
.TP
Type& get ();
Removes and returns a reference to the first-in item on the queue. If there are
no elements in the queue, an
\f3\f3Error\f1\f1
exception is raised.
.TP
inline Boolean is_empty () const;
Returns
TRUE
if there are no items in the queue. Otherwise, this function
returns
FALSE .
.TP
inline long length () const;
Returns the number of elements in the queue.
.TP
inline Type& look ();
Returns the first-in item on the queue. If there are no elements in the queue,
an
\f3\f3Error\f1\f1
exception is raised.
.TP
Boolean next ();
Advances the current position to the next element in the queue and returns
TRUE .
If the current position is invalid, this function sets the current
position to the first element and returns
TRUE .
If the current position is the
last element of the queue, this function invalidates the current position and